{extend name="mainadmin@layouts/base" /}
{block name="head" }
<link href="__STATIC__/main/css/stylesheets/page/goods.css?v=1" rel="stylesheet"/>
<link href="__STATIC__/main/css/stylesheets/uploadify/uploadify.min.css" rel="stylesheet"/>
{/block}
{block name="main" }

<header>
    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-ellipsis-v"></i>
                <strong>{$row['goods_id']>0?"编辑商品":"添加商品"}</strong>
            </li>
        </ul>

        <a class="pull-right pointer p-r" data-toggle="back" title="返回"><i class="fa fa-reply"></i></a>
    </div>
</header>
<form class="form-horizontal form-validate form_vbox" method="post" action="{:url('info')}">
    <section class="vbox">
        <section class="scrollable wrapper w-f">

            <section class="panel panel-default">
                <div class="panel-body">

                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品名称：</label>
                        <div class="col-sm-7 must">
                            <input type="text" class="input-max" data-rule-maxlength="200" data-rule-required="true"
                                   data-msg-required="商品名称不能为空" name="goods_name" value="{$row.goods_name}">
                        </div>
                    </div>

                    <!--<div class="form-group">
                        <label class="col-sm-2 control-label">商品简称：</label>
                        <div class="col-sm-5">
                            <input type="text" class="input-max" data-rule-maxlength="60" name="short_name"
                                   value="{$row.short_name}">
                        </div>
                    </div>-->




                    <div class="form-group">
                        <label class="col-sm-2 control-label">市场价：</label>
                        <div class="col-sm-4">
                            <input type="text" class="input-medium" name="market_price" data-rule-ismoney="true" value="{$row.market_price}">元
                        </div>
                    </div>

                    <!--<div class="form-group">
                        <label class="col-sm-2 control-label">销售价：需要注释</label>
                        <div class="col-sm-4">
                            <input type="text" class="input-medium" name="shop_price" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="销售价不能为空" value="{$row.shop_price}">
                            元<span  style="color:#f30;"> *</span>
                        </div>
                    </div>-->

                    <div class="form-group">
                        <label class="col-sm-2 control-label">省代理价：</label>
                        <div class="col-sm-2">
                            <input type="text" class="input-medium" name="shengmoney" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="省代理价不能为空" value="{$row.shengmoney}">
                            元<span  style="color:#f30;"> *</span>
                        </div>

                        <label class="col-sm-1 control-label" style="width: 136px">省代理起订数：</label>
                        <div class="col-sm-3">
                            <input type="text" class="input-medium" name="shengminnum" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="" value="{$row.shengminnum}">
                            <span  style="color:#f30;"> * 0 表示不限制最低起订数</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">市代理价：</label>
                        <div class="col-sm-2">
                            <input type="text" class="input-medium" name="shimoney" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="市代理价不能为空" value="{$row.shimoney}">
                            元<span  style="color:#f30;"> *</span>
                        </div>

                        <label class="col-sm-1 control-label" style="width: 136px">市代理起订数：</label>
                        <div class="col-sm-3">
                            <input type="text" class="input-medium" name="shiminnum" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="" value="{$row.shiminnum}">
                            <span  style="color:#f30;"> * 0 表示不限制最低起订数</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">区代理价：</label>
                        <div class="col-sm-2">
                            <input type="text" class="input-medium" name="qumoney" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="区代理价不能为空" value="{$row.qumoney}">
                            元<span  style="color:#f30;"> *</span>
                        </div>

                        <label class="col-sm-1 control-label" style="width: 136px">区代理起订数：</label>
                        <div class="col-sm-3">
                            <input type="text" class="input-medium" name="quminnum" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="" value="{$row.quminnum}">
                            <span  style="color:#f30;"> * 0 表示不限制最低起订数</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">街道代理价：</label>
                        <div class="col-sm-2">
                            <input type="text" class="input-medium" name="jiedaomoney" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="街道代理价不能为空" value="{$row.jiedaomoney}">
                            元<span  style="color:#f30;"> *</span>
                        </div>


                        <label class="col-sm-1 control-label" style="width: 136px">街道代理起订数：</label>
                        <div class="col-sm-3">
                            <input type="text" class="input-medium" name="jiedaominnum" min="0" data-rule-ismoney="true" data-rule-required="true" data-msg-required="" value="{$row.jiedaominnum}">
                            <span  style="color:#f30;"> * 0 表示不限制最低起订数</span>
                        </div>
                    </div>



                    <!--
                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品分类：</label>
                        <div class="col-sm-3 must">
                            <select name="cid" style="width:100%;" data-toggle="select2" data-notsearch="true" data-placeholder="选择分类">
                                <option value="">选择分类</option>
                                {$classListOpt|raw}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品品牌：</label>
                        <div class="col-sm-3 ">
                            <select name="brand_id" style="width:100%;" data-toggle="select2" data-notsearch="true" >
                                <option value="">选择品牌</option>
                                {$brandListOpt|raw}
                            </select>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">运费计算方式：</label>
                        <div class="col-sm-10">
                            <label class="radio-inline">
                                <input name="undertake" value="0" {$row.freight_template|tplckval='=0' ,'checked',true}
                                class="js_undertake" type="radio">卖家承担运费
                            </label>
                            <label class="radio-inline">
                                <input name="undertake" value="1" {$row['freight_template']>0 ||
                                $row['freight_template'] ==-1?'checked':''} class="js_undertake
                                js_freight_container_show" type="radio">
                                买家承担运费
                            </label>
                            <label class="js_freight_container"
                                   style="display:{$row['freight_template'] > 0 || $row['freight_template'] ==-1?'':'none'}; position:relative;">
                                <select name="freight_template" data-rule-required="true" aria-required="true"
                                        aria-invalid="true">
                                    <option value="-1" selected>-- 使用默认运费模板 --</option>
                                    {volist name="ShippingTpl" id="sfrow" }
                                    <option value="{$sfrow.sf_id}" {$row[
                                    'freight_template']==$sfrow['sf_id']?'selected':''}>{$sfrow.sf_name}{$sfrow['is_default']==1?'(默认)':''}</option>
                                    {/volist}
                                    {empty name="ShippingTpl"}
                                    <option value="0" selected>-- 没有运费模板 --</option>
                                    {/empty}
                                </select>
                            </label>

                        </div>
                    </div>
                    {if condition="$settings.sys_model_distribution == 1"}
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否参与分销：</label>
                        <div class="col-sm-10">
                            <label class="radio-inline">
                                <input name="is_dividend" value="0" {$row.is_dividend|tplckval='<1' ,'checked'}
                                type="radio" >否
                            </label>
                            <label class="radio-inline">
                                <input name="is_dividend" value="1" {$row.is_dividend|tplckval='>0' ,'checked'}
                                type="radio" >是
                            </label>
                            <label class="radio-inline red">
                                不参与分销则不会产生佣金.
                            </span>
                        </div>
                    </div>
                    {/if}
                    <div class="form-group ">
                        <label class="col-sm-2 control-label">商品类型：</label>
                        <div class="col-sm-10">
                            {if $row.goods_id > 0}
                            <label class="radio-inline">
                                <input name="goods_type" value="{$row.goods_type}" type="radio" checked="" >{$goodsType[$row.goods_type]}
                            </label>
                            {else}
                            {foreach $goodsType as $type=>$name}
                            <label class="radio-inline">
                                <input name="goods_type" value="{$type}" {$type|tplckval='=0' ,'checked'} type="radio" >{$name}
                            </label>
                            {/foreach}
                            {/if}
                            <label class="radio-inline red">
                                商品添加后不能修改商品类型
                            </label>
                        </div>
                    </div>
                    <div class="form-group hide">
                        <label class="col-sm-2 control-label">是否出售：</label>
                        <div class="col-sm-6">
                            <label class="radio inline">
                                <input type="checkbox" name="is_alone_sale" value="1" {$row['is_alone_sale']==1 ||
                                $row['goods_id']==0?'checked':''}> 打勾表示能作为普通商品销售，否则只能作为配件、赠品或欢乐豆兑换.
                            </label>
                        </div>
                    </div>

                    -->

                    {if condition="$row['supplyer_id'] > 0" }
                    <div class="line line-dashed line-lg pull-in" style="width:99%;"></div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品状态：</label>
                        <div class="col-sm-5 m-t-mc">
                            {$goods_status[$row['isputaway']]}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">操作选项：</label>

                        <div class="col-sm-5">
                            <label class="radio-inline">
                                <input type="radio" name="opt" value="0" checked/>不操作
                            </label>
                            {if condition="$row['isputaway'] == 10" }
                            <label class="radio-inline">
                                <input type="radio" name="opt" value="1"/>允许上架
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="opt" value="11"/>拒绝上架
                            </label>
                            {elseif condition="$row['isputaway'] == 1"}
                            <label class="radio-inline">
                                <input type="radio" name="opt" value="12"/>下架商品
                            </label>
                            {/if}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">操作备注：</label>
                        <div class="col-sm-8">
                            <textarea name="opt_remark" style=" width:80%; height:100px;"></textarea>
                        </div>
                    </div>
                    {/if}
                </div>
                <header>
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#basicInfo" data-toggle="tab">基本信息</a></li>
                        <!--<li><a href="#otherInfo" data-toggle="tab">其它信息</a></li>-->
                        {if condition="$settings.sys_model_shop_goods_buy_brokerage == 1
                        || $settings.sys_model_shop_goods_use_integral == 1
                        || $settings.sys_model_shop_bonus == 1
                        || $settings.sys_model_shop_goods_give_integral == 1
                        || $settings.sys_model_shop_goods_urole_price == 1
                        || $settings.sys_model_shop_goods_volume_price == 1"}
                        <li><a href="#promotions" data-toggle="tab">促销优惠</a></li>
                        {/if}
                        <!--<li class="div-set-tab hide"><a href="#div-set" data-toggle="tab">限制配置</a></li>-->
                        <li><a href="#details" data-toggle="tab" class="hide">PC商品详情</a></li>
                        {gt name="$row.goods_id" value="0"}
                        <li><a href="#log" data-toggle="tab">操作日志</a></li>
                        {/gt}
                        
                        <li class="pay-type"><a href="#paytType" data-toggle="tab">支付方式</a></li>
                    </ul>
                </header>

                <div class="tab-content">
                    <div class="tab-pane active" id="basicInfo">
                        {include file="jxcshop@sys_admin/goods/basicInfo" /}
                        {include file="jxcshop@sys_admin/goods/sku" /}
                    </div>
                    <div class="tab-pane" id="details">
                        <div class="col-sm-10">

                        </div>
                    </div>
                    <div class="tab-pane" id="paytType">
                        {include file="jxcshop@sys_admin/goods/paytType" /}
                    </div>
                    <div class="tab-pane" id="otherInfo">
                        {include file="jxcshop@sys_admin/goods/otherInfo" /}
                    </div>

                    <div class="tab-pane" id="div-set">
                        {include file="jxcshop@sys_admin/goods/div_set" /}
                    </div>



                    <div class="tab-pane" id="attribute">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品模型：</label>
                            <div class="col-sm-3">
                                <select name="type_model" id="type_model" class="input-max " data-toggle="select2"
                                        onChange="getGoodsAttriBute()">
                                    <option value="0" selected>请选择模型</option>
                                    {$modelListOpt|raw}
                                </select>
                            </div>
                        </div>
                        <div id="goods_attribute_box">
                        </div>
                        <script type="text/javascript">
                            function getGoodsAttriBute() {
                                var type_model = $("#type_model").val();
                                $('#goods_attribute_box').html('');
                                if (type_model < 1) return false;
                                jq_ajax('{:_url("getAttriBute",array("goods_id"=>$row["goods_id"],"model_id"=>"【type_model】"))}', '', function (res) {
                                    if (res.code == 0) {
                                        _alert(res.msg);
                                        return false;
                                    }
                                    $('#goods_attribute_box').html(res.data.content);
                                });
                            }
                            $(function () {
                                getGoodsAttriBute();
                            });
                        </script>

                    </div>
                    {gt name="$row.goods_id" value="0"}
                    <div class="tab-pane" id="log">
                        <table class="table table-bordered ">
                            <thead>
                            <tr>
                                <th width="150">记录时间</th>
                                <th width="150">操作者</th>
                                <th width="100">状态</th>
                                <th>备注</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="goodsLog" id="log"}
                            <tr>
                                <td>{$log.log_time|dateTpl}</td>
                                <td>{$log['opt_source']=='admin'?'平台-'.adminInfo($log['operator']):'供应商'}</td>
                                <td>{$log['status']}</td>
                                <td>{$log.log_info}</td>
                            </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                    {/gt}

                </div>
            </section>
        </section>
        <footer class="footer bg-white b-t p-t">
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-1">
                    <input name="goods_id" id="goods_id" type="hidden" value="{$row.goods_id|intval}">

                    <button type="submit" class="btn btn-primary js_save_submit" data-loading-text="保存中...">保存
                    </button>
                    <button type="button" class="btn btn-default" data-toggle="back">取消</button>
                </div>
            </div>
        </footer>
    </section>
</form>
{/block}


{block name="footer" }
<script type="text/javascript">
    seajs.use(["dist/plupload/init.js", "dist/goods/init.js","dist/plupload/file.js",])
</script>
<script>
    $(function(){
        var goods_type = $("input[name='goods_type']:checked").val();
        changeType(goods_type);
        $("input[name='goods_type']").on('change',function(){
            goods_type = $(this).val();
            changeType(goods_type);
        })

        function changeType(goods_type) {
            console.log(goods_type)
            $('.div-set').addClass('hide');
            if(goods_type==0){
                $('.pay-type').addClass('hide');
            }else{
                $('.pay-type').removeClass('hide');
            }
            $('.div-set'+goods_type).removeClass('hide');
            if (goods_type == 5 ) {
                $('.div-set-tab').addClass('hide');
                    var index = $('.nav-tabs').children('.active').index();
                if (index == 2) {
                    $('.nav-tabs').children('li').removeClass("active");
                    $('.nav-tabs').children('li').eq(0).addClass("active");
                    $('.tab-content').children('.tab-pane').removeClass("active");
                    $('.tab-content').children('.tab-pane').eq(0).addClass("active");
                }
            }else{
                $('.div-set-tab').removeClass('hide');
            }
        }
    })
</script>


{/block}